import {validatInteger} from '@/utils/validate';

export const ruleName = (rule, value, callback,text) => {
    console.log('value',value)
    if (value === '') {
      callback(new Error(text+'不能为空'));
    } else {
      if (value.length<3||value.length>20) {
        callback(new Error(text+'只能输入3~20位'));
      }
      callback();
    }
  };

  export const regMinScore = (rule, value, callback,max,nextCallback) => {
    let text = '最小积分';
    if (value === '') {
      callback(new Error(text+'不能为空'));
    } else {
      if (!validatInteger(value)) {
        callback(new Error(text+'只能为大于零的整数'));
      }
      if (parseInt(value) > parseInt(max)) {
        callback(new Error(text+'不能大于上限积分'));
      }
      nextCallback();
      callback();
    }
  };

  export const regMaxScore = (rule, value, callback,min,nextCallback) => {
    let text = '上限积分';
    if (value === '') {
      callback(new Error(text+'不能为空'));
    } else {
      if (!validatInteger(value)) {
        callback(new Error(text+'只能为大于零的整数'));
      }
      if (parseInt(value) < parseInt(min)) {
        callback(new Error(text+'不能小于最小积分'));
      }
      nextCallback();
      callback();
    }
  };
  
  export const maxTotalScore = (rule, value, callback,dayLimit,nextCallback) => {
    let text = '派发总上限';
    if (value === '') {
      callback(new Error(text+'不能为空'));
    } else {
      if (!validatInteger(value)) {
        callback(new Error(text+'只能为大于零的整数'));
      }
      if (parseInt(value) < parseInt(dayLimit)) {
        callback(new Error(text+'不能小于单日派发上下车'));
      }
      nextCallback();
      callback();
    }
  };

  export const dayTotalScore = (rule, value, callback,Limit,nextCallback) => {
    let text = '单日派发上限';
    if (value === '') {
      callback(new Error(text+'不能为空'));
    } else {
      if (!validatInteger(value)) {
        callback(new Error(text+'只能为大于零的整数'));
      }
      if (parseInt(value) > parseInt(Limit)) {
        callback(new Error(text+'不能大于派发总上限'));
      }
      nextCallback();
      callback();
    }
  };

  export const dateNum = (rule, value, callback,text) => {
    if (value === '') {
      callback(new Error(text+'不能为空'));
    } else {
      if (!validatInteger(value)) {
        callback(new Error(text+'只能为大于零的整数'));
      }
      callback();
    }
}

  

  